package org.jfteam.common.repository.query;

import org.jfteam.common.repository.persistence.BaseDO;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * Description: 描述
 * Author:      fengwenping
 * Date:        2021/3/28 14:07
 */
public abstract class BaseQuery<ID extends Serializable> extends BaseDO<ID> {

    /**
     * 默认每页记录行数
     */
    public static final int DEFAULT_PAGE_SIZE = 10;

    protected int pageNo = 1;
    protected int pageSize = DEFAULT_PAGE_SIZE;
    protected int startRow = (getPageNo() - 1) * getPageSize() + 1;
    protected int endRow = getPageNo() * getPageSize();

    public BaseQuery() {
    }

    public BaseQuery(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.startRow = (this.pageNo - 1) * pageSize + 1;
        this.endRow = this.pageNo * this.pageSize - 1;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

    public int getEndRow() {
        return endRow;
    }

    public void setEndRow(int endRow) {
        this.endRow = endRow;
    }
}
